import index from '../views/index.vue'
import User from '../views/User.vue'
import Product from '../views/Product.vue'
import Cart from '../views/cart.vue'
import { createRouter, createWebHashHistory } from "vue-router";

const router = createRouter({
    history : createWebHashHistory(),
    routes : [
        {path : '/',redirect:'/index',meta:{title:'首页'},name:'index'},//路由重定向
        {path:'/index',component:index,meta:{title:'首页'}},
        {path:'/user',component:User,meta:{title:'用户中心'}},
        {path:'/cart',component:Cart,meta:{title:'购物车'}},
        {path:'/product',component:Product,meta:{title:'商品'}},
    ]
})
router.beforeEach((to,from,next)=>{
    document.title = to.meta.title
    next()
})
//暴露出来
export default router